<template>
<div>
  <h1>我是app组件</h1>
  {{count}}
  <hr>
  <Child ref="childComp"/>
</div>
</template>


<script>
import Child from '@/components/Child'
export default {
  name:"App",
  components:{Child},
  data(){
    return {
      count:0,
    }
  },
  mounted(){
    // 初始化的时候，在这里对某个子组件绑定自定义事件
    this.$refs.childComp.$once("changeCount", this.changeCount);

  },
  methods:{
    changeCount(value){
      console.log(value);
      this.count +=value;
    }
  }
}
</script>